// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Goal Block Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 11 : TYPE_GOALBLOCK

// Function declarations
reserve function GoalBlock_DebugDraw
reserve function GoalBlock_DebugSpawn

// Static Values

// Tables

function GoalBlock_DebugDraw
	DrawSprite(0)
end function


function GoalBlock_DebugSpawn
	temp5 = 11
	temp4 = 0
	CallFunction(DebugMode_SpawnObject)
	object[arrayPos0].drawOrder = 4
	object[arrayPos0].groupID = GROUP_BLOCKS
end function


event ObjectMain
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		CallFunction(SpecialSetup_Function10)
		if checkResult > 0
			object[currentPlayer].state = PlayerObject_Blank
			object[currentPlayer].xvel = 0
			object[currentPlayer].yvel = 0
			object[currentPlayer].speed = 0
			object.value0 = 0
			object[currentPlayer].interaction = 0
			ResetObjectEntity(20, TypeName[Special Finish], 0, 0, 0)
			object[20].priority = PRIORITY_ACTIVE
			PlaySfx(SfxName[Exit SS], 0)
			stage.timeEnabled = 0
			stage.pauseEnabled = 0
		end if
	next
end event


event ObjectDraw
	CallFunction(SpecialSetup_Function9)
	temp2 = oscillation
	temp2 &= 15
	temp2 >>= 3
	DrawSpriteXY(temp2, temp0, temp1)
end event


event ObjectStartup
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 201, 76)
	SpriteFrame(-12, -12, 24, 24, 201, 176)
	foreach (TypeName[Goal Block], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].groupID = GROUP_BLOCKS
	next
	SetTableValue(TypeName[Goal Block], DebugMode_ObjCount, DebugMode_TypeTable)
	SetTableValue(GoalBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(GoalBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 201, 76)
end event
